<template>
  <el-button @click="playAll"
    ><span class="iconfont">&#xea6e;</span>播放全部</el-button
  >
</template>

<script lang="ts" setup>
import userFooterStore from '../store/footer';
import { storeToRefs } from 'pinia';
import { Song } from '../model';
const props = defineProps<{
  songs: Song[];
}>();

const footer = userFooterStore();
const { songList, current, songNum } = storeToRefs(footer);

//播放全部
const playAll = () => {
  const temp: number = songNum.value;
  props.songs.forEach((item) => {
    const notInList = songList.value.every((song) => song.id != item.id);
    if (notInList && (item.available == '0' || item.available == '8')) {
      songList.value.push(item);
    }
  });
  current.value = temp;
};
</script>

<style lang="less" scoped>
.el-button {
  .iconfont {
    margin-right: 5px;
  }
  color: #ffffff;
  background-color: #1fcf9e;
  border-radius: 18px;
  font-size: 14px;
  width: 120px;
  height: 34px;
  &:active {
    background-color: rgba(31, 207, 158, 0.8);
    border: none;
  }
  &:hover {
    background-color: rgba(31, 207, 158, 0.8);
  }
}
</style>
